/***************************************************************************\
 * Copyright (C) by Keio University
 * Size.hpp created in 08 2012.
 * Mail : fdesorbi@hvrl.ics.keio.ac.jp
 *
 * Size.hpp is part of the HVRL Engine Library.
 *
 * The HVRL Engine Library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * The HVRL Engine Library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
\***************************************************************************/

#ifndef HVRL_SIZE_HPP__
#define HVRL_SIZE_HPP__

#include <iostream>
#include <cassert>

namespace hvrl{

struct Size{

	Size(void):
		width(0), height(0){}

	Size(const unsigned int& w, const unsigned int& h):
		width(w), height(h){}

	Size(const Size& s):
		width(s.width), height(s.height){}

	~Size(void){};

	unsigned int getWidth(void)const { return this->width; }

	unsigned int getHeight(void)const { return this->height; }

	Size operator+(const Size& s1) {
		unsigned int w = this->width + s1.width;
		unsigned int h= this->height + s1.height;
		return Size(w,h);
	}

	Size& operator+=(const Size& s) {
		this->width += s.width;
		this->height += s.height;
		return *this;
	}

	Size operator*(const unsigned int& v) {
		unsigned int w = this->width * v;
		unsigned int h= this->height * v;
		return Size(w,h);
	}

	Size& operator*=(const unsigned int& v) {
		this->width *= v;
		this->height *= v;
		return *this;
	}

	Size operator/(const unsigned int& v) {
		assert(v != 0);
		unsigned int w = this->width / v;
		unsigned int h= this->height / v;
		return Size(w,h);
	}

	Size& operator/=(const unsigned int& v) {
		assert(v != 0);
		this->width /= v;
		this->height /= v;
		return *this;
	}

	Size operator-(const Size& s) {
		unsigned int w = this->width - s.width;
		unsigned int h= this->height - s.height;
		return Size(w,h);
	}

	Size& operator-=(const Size& s) {
		this->width -= s.width;
		this->height -= s.height;
		return *this;
	}

	Size& operator=(const Size& s) {
		this->width = s.width;
		this->height = s.height;
		return *this;
	}

	bool operator==(const Size& s) {
		return (this->width == s.width) && (this->height == s.height);
	}

	bool operator!=(const Size& s) {
		return (this->width != s.width) || (this->height != s.height);
	}

	friend std::ostream &operator<<(std::ostream &out, const Size& s){
	        out<<"["<< s.width <<","<< s.height <<"]";
	        return out;
	}

public:
	unsigned int width;

	unsigned int height;


};

}

#endif
